<?php
class Member_groupAction extends CommonAction {
	public function index(){
        $map['site_id']=$this->siteid;
        //$map['user_id']=session(C('USER_AUTH_KEY'));
		$pid_list=$this->dao->getList2(0,0,$map);
		$this->assign('pid_list',$pid_list);
		$this->display();
	}
	public function delete(){
		if($this->_get('id')){
			$map['pid']=$this->_get('id');
			$re=$this->dao->where($map)->find();
			if($re){
				$this->error('该分类包含了子导航,请先删除子导航');
			}else{
				$all=$this->dao->where('id in('.$this->_get('id').')')->select();
				foreach($all as $k=>$v){
					//删除图片
					$this->delImgBypath($v['img_url']);
				}
				parent::delete();
			}
		}
	}
	
	
	
	public function add(){
        $map['site_id']=$this->siteid;
		$this->pid_list=$this->dao->getList2(0,0,$map);
		parent::add();
	}
	public function edit(){
		$map['site_id']=$this->siteid;
		$this->pid_list=$this->dao->getList2(0,0,$map);
		
		
		parent::edit();
	}
	
	//重写更新方法,防止用户选择自己作为父分类
	public function update(){
		if($this->_post('pid')==$this->_post('id')){
			$this->error('您不能选择当前分类作为父类');
		}else{
			parent::update();
		}
	}
	public function insert(){
		$_POST['site_id'] =$this->siteid;
		$_POST['user_id'] = session(C('USER_AUTH_KEY'));
		parent::insert();
	}
}

?>